package com.xs.valid.demo.common;

/**
 * 封装json返回
 *
 * @author www
 */
public class ResultUtils {

    public static ResultJson success() {
        return new ResultJson<>(new ResultJson.HeaderBean(RestEnum.SUCCESS.getStatus(), RestEnum.SUCCESS.getMessage()), null);
    }


    public static ResultJson success(Object o) {
        return new ResultJson<>(new ResultJson.HeaderBean(RestEnum.SUCCESS.getStatus(), RestEnum.SUCCESS.getMessage()), o);
    }


    public static ResultJson error(int code, String msg) {
        return new ResultJson<>(new ResultJson.HeaderBean(code, msg), null);
    }

    public static ResultJson error(RestEnum restEnum) {
        return new ResultJson<>(new ResultJson.HeaderBean(restEnum.getStatus(), restEnum.getMessage()), null);
    }

    public static ResultJson error(RestEnum restEnum, String msg) {
        return new ResultJson<>(new ResultJson.HeaderBean(restEnum.getStatus(), msg), null);
    }
}
